//编写A02，定义方法find，实现查找字符串数组中的元素查找，
// 并返回索引，如果找不到，返回-1
public class Homework12 {
    public static void main(String[] args) {
        String[] arrStr = {"Hello", "world", "HelloWorld", "make", "马可"};
        A02 a02 = new A02(arrStr);
        int index = a02.find("马可");
        if (index != -1) {
            System.out.println("字符串已找到！索引位置为：" + index);
        } else {
            System.out.println("字符串未找到！");
        }
    }
}

class A02 {
    String[] arrStr;
    A02(String[] arrStr) {
        this.arrStr = arrStr;
    }
    public int find(String str) {
        for (int i = 0; i < arrStr.length; i++) {
            if (str.equals(arrStr[i])) {
                return i;
            }
        }
        return -1;
    }
}